package org.chameleon.threadpool.manager;

import org.chameleon.datasource.manager.AbsJzConfigManager;
import org.chameleon.threadpool.JsonPoolConvert;
import org.chameleon.threadpool.entity.ThreadPoolConfig;


/**
 * Apollo配置管理中心，负责读取&更新对应的配置
 */
public class JzPoolConfigManger extends AbsJzConfigManager<ThreadPoolConfig> {

    private static final String CACHE_PREFIX = "JzPoolConfigManger:";

    public JzPoolConfigManger(String appName) {
        super(appName, new JsonPoolConvert());
    }


    @Override
    public String getGroup(ThreadPoolConfig threadPoolConfig) {
        return "chameleon";
    }

    @Override
    public String getKey(ThreadPoolConfig threadPoolConfig) {
        return threadPoolConfig.getPoolName();
    }

    @Override
    public String buildCacheKey(ThreadPoolConfig threadPoolConfig) {
        return CACHE_PREFIX + ":" + getGroup(threadPoolConfig) + ":" + getKey(threadPoolConfig);
    }
}
